/**
 * https://leetcode.cn/submissions/detail/558752584/
 * 03. 无重复字符的最长子串
 * medium, 黄伟杰 2024.8.26
 * 滑动窗口
 */

#include <bits/stdc++.h>
using namespace std;
class Solution
{
    int a[200] = {0};

public:
    int lengthOfLongestSubstring(string s)
    {
        int max_num = 0;
        for (int i = 0, j = 0; j < s.size(); j++)
        {
            char ch = s[j];
            a[ch]++;
            while (a[ch] > 1)
            {
                a[s[i]]--;
                i++;
            }
            max_num = max(max_num, j - i + 1);
        }
        return max_num;
    }
};